#pragma once
#include <time.h>
#include <sys/types.h>
using namespace std;
/********************************************************************
//	Created:	2013/2/7  15:28
//	File Name: 	G:\U_DISK_Path\NetEngine_Windows\NetEngine_SourceCode\NetEngine_Lib\NetEngine_PublicOperator\NetEngine_OperatorTime\NetEngine_OperatorTime.h
//	File Path:	G:\U_DISK_Path\NetEngine_Windows\NetEngine_SourceCode\NetEngine_Lib\NetEngine_PublicOperator\NetEngine_OperatorTime
//	File Base:	NetEngine_OperatorTime
//	File Ext:	h
//  Project:    NetSocketEngine(网络通信引擎)
//	Author:		qyt
//	Purpose:	时间天数跨度计算器
//	History:
*********************************************************************/
class CBaseLib_OperatorTimeSpan
{
public:
    CBaseLib_OperatorTimeSpan();
    CBaseLib_OperatorTimeSpan(time_t nTime64);
    CBaseLib_OperatorTimeSpan(long lDays,int nHours,int nMins,int nSecs);
public:
    __int64 OperatorTimeSpan_GetDays();
    __int64 OperatorTimeSpan_GetTotalHours();
    long OperatorTimeSpan_GetHours();
    __int64 OperatorTimeSpan_GetTotalMinutes();
    long OperatorTimeSpan_GetMinutes();
    __int64 OperatorTimeSpan_GetTotalSeconds();
    long OperatorTimeSpan_GetSeconds();
    time_t OperatorTimeSpan_GetTimeSpan();
public:
    CBaseLib_OperatorTimeSpan operator + (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    CBaseLib_OperatorTimeSpan operator - (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    CBaseLib_OperatorTimeSpan& operator += (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    CBaseLib_OperatorTimeSpan& operator -= (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
public:
    BOOL operator == (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    BOOL operator != (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    BOOL operator < (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    BOOL operator > (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    BOOL operator <= (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    BOOL operator >= (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
private:
    time_t m_timeSpan;
};

class CBaseLib_ObjectTime
{
public:
    static CBaseLib_ObjectTime GetCurrentTime();
public:
    CBaseLib_ObjectTime();
    CBaseLib_ObjectTime(time_t nTime64);
    CBaseLib_ObjectTime(int nYear,int nMonth,int nDay,int nHour,int nMin,int nSec,int nDST = -1);
    CBaseLib_ObjectTime(unsigned short wDosDate,unsigned short wDosTime,int nDST = -1);
public:
    struct tm* OperatorTime_GetGmtTime(struct tm *pSt_Time) const;
    struct tm* OperatorTime_GetLocalTime(struct tm *pSt_Time) const;

    time_t OperatorTime_GetTime() const;

    int OperatorTime_GetYear() const;
    int OperatorTime_GetMonth() const;
    int OperatorTime_GetDay() const;
    int OperatorTime_GetHour() const;
    int OperatorTime_GetMinute() const;
    int OperatorTime_GetSecond() const;
    int OperatorTime_GetDayOfWeek() const;
public:
    CBaseLib_ObjectTime& operator = (time_t nTime64);

    CBaseLib_ObjectTime& operator += (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);
    CBaseLib_ObjectTime& operator -= (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan);

    CBaseLib_OperatorTimeSpan operator - (CBaseLib_ObjectTime m_OperatorTime) const;
    CBaseLib_ObjectTime operator - (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan) const;
    CBaseLib_ObjectTime operator + (CBaseLib_OperatorTimeSpan m_OperatorTimeSpan) const;
public:
    BOOL operator == (CBaseLib_ObjectTime m_OperatorTime) const;
    BOOL operator != (CBaseLib_ObjectTime m_OperatorTime) const;
    BOOL operator < (CBaseLib_ObjectTime m_OperatorTime) const;
    BOOL operator > (CBaseLib_ObjectTime m_OperatorTime) const;
    BOOL operator <= (CBaseLib_ObjectTime m_OperatorTime) const;
    BOOL operator >= (CBaseLib_ObjectTime m_OperatorTime) const;
private:
    time_t m_time;
};
